package com.bt.lms.ui.page.info;

import com.bt.lms.ui.action.teacher.basic.info.*;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;

/**
 * 新增教师界面
 */
public class PageAddTeacherBasicInfo extends VBox {

    private Integer width=1140;
    private Integer height=900;

    //证号文本框
    private TextField accountLb;
    //证件类型文本框
    private TextField certificateLb;
    //1为男，2为女
    private ToggleGroup toggleGroup;
    //男
    private RadioButton genderRBtnMan;
    //女
    private RadioButton genderRBtnWoman;

    //政治面貌
    private ComboBox politicsStatusCom;


    public TextField getAccountLb() {
        return accountLb;
    }

    public void setAccountLb(TextField accountLb) {
        this.accountLb = accountLb;
    }

    public TextField getCertificateLb() {
        return certificateLb;
    }

    public void setCertificateLb(TextField certificateLb) {
        this.certificateLb = certificateLb;
    }

    public ToggleGroup getToggleGroup() {
        return toggleGroup;
    }

    public void setToggleGroup(ToggleGroup toggleGroup) {
        this.toggleGroup = toggleGroup;
    }

    public RadioButton getGenderRBtnMan() {
        return genderRBtnMan;
    }

    public void setGenderRBtnMan(RadioButton genderRBtnMan) {
        this.genderRBtnMan = genderRBtnMan;
    }

    public RadioButton getGenderRBtnWoman() {
        return genderRBtnWoman;
    }

    public void setGenderRBtnWoman(RadioButton genderRBtnWoman) {
        this.genderRBtnWoman = genderRBtnWoman;
    }

    public ComboBox getPoliticsStatusCom() {
        return politicsStatusCom;
    }

    public void setPoliticsStatusCom(ComboBox politicsStatusCom) {
        this.politicsStatusCom = politicsStatusCom;
    }

    public PageAddTeacherBasicInfo(){

        this.setMaxWidth(width);
        this.setMaxHeight(height);


        //当前位置
        HBox locationHBox = new HBox();
        locationHBox.setPadding(new Insets(15,15,15,15));
        locationHBox.setPrefWidth(width);
        double locationHBoxHeight=height*0.05;
        locationHBox.setPrefHeight(locationHBoxHeight);
        Label label1 = new Label("当前位置：🏠>教学管理>教师管理>新增教师");
        Font font = Font.font("仿宋", FontWeight.THIN, FontPosture.REGULAR,18);
        label1.setFont(font);
        locationHBox.getChildren().add(label1);
        this.getChildren().add(locationHBox);

        //数据大盒子
        VBox totalVBox = new VBox();
        totalVBox.setPadding(new Insets(15,15,15,15));
        double totalVBoxHeight=height*0.9;
        totalVBox.setPrefHeight(totalVBoxHeight);
        totalVBox.setPrefWidth(width);
        ScrollPane scrollPane = new ScrollPane();//滚动条
        scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);//只能竖向滚动不能横向滚动
        scrollPane.setContent(totalVBox);
        this.getChildren().add(scrollPane);

        initTeacherInfo(totalVBox);//教师基本信息
        initSaveCancelBtn(totalVBox);//保存/取消按钮

    }

    /**
     * 教师基本信息
     * @param totalVBox 大盒子
     */
    private void initTeacherInfo(VBox totalVBox){

        //教师基本信息数据大盒子
        VBox dataVBox = new VBox();
        dataVBox.setPadding(new Insets(15,15,15,15));
        double dataHBoxHeight=height*0.2;
        dataVBox.setPrefHeight(dataHBoxHeight);
        dataVBox.setPrefWidth(width);
        totalVBox.getChildren().add(dataVBox);
        //教师基本信息标题
        HBox topHBox = new HBox();
        topHBox.setPadding(new Insets(15,15,15,15));
        double topHBoxHeight=height*0.01;
        topHBox.setMaxHeight(topHBoxHeight);
        topHBox.setPrefWidth(width);
        topHBox.setBackground(new Background(new BackgroundFill(Color.LIGHTGRAY,null,null)));
        Label addLb = new Label("教师基本信息");
        Font font1 = Font.font("仿宋", FontWeight.BOLD, FontPosture.REGULAR, 20);
        Color color = Color.rgb(12, 12, 12, 1);
        addLb.setFont(font1);
        addLb.setTextFill(color);
        topHBox.getChildren().add(addLb);
        dataVBox.getChildren().add(topHBox);

        //保存按钮盒子
        HBox saveHBox = new HBox();
        saveHBox.setSpacing(20);
        saveHBox.setAlignment(Pos.CENTER_RIGHT);
        saveHBox.setPadding(new Insets(15,15,15,15));
        double saveHBoxHeight=height*0.01;
        saveHBox.setMaxHeight(saveHBoxHeight);
        saveHBox.setPrefWidth(width);
        Button savaBtn = new Button("保存");
        Button cancelBtn = new Button("取消");
        saveHBox.getChildren().addAll(savaBtn,cancelBtn);
        dataVBox.getChildren().add(saveHBox);


        //教师基本信息数据盒子
        HBox teacherInfoHBox = new HBox();
        teacherInfoHBox.setPadding(new Insets(15,15,15,15));
        double teacherInfoVBoxHeight=height*0.3;
        teacherInfoHBox.setMaxHeight(teacherInfoVBoxHeight);
        teacherInfoHBox.setPrefWidth(width);
        dataVBox.getChildren().add(teacherInfoHBox);



        //教师基本信息左数据盒子
        VBox teacherInfoLeftVBox = new VBox();
        teacherInfoLeftVBox.setSpacing(20);
        teacherInfoLeftVBox.setPadding(new Insets(15,15,15,15));
        double teacherInfoLeftVBoxHeight=height*0.3;
        teacherInfoLeftVBox.setMaxHeight(teacherInfoLeftVBoxHeight);
        teacherInfoLeftVBox.setPrefWidth(width*0.5);
        teacherInfoHBox.getChildren().add(teacherInfoLeftVBox);

        //教师基本信息右数据盒子
        VBox teacherInfoRightVBox = new VBox();
        teacherInfoRightVBox.setSpacing(20);
        teacherInfoRightVBox.setPadding(new Insets(15,15,15,15));
        double teacherInfoRightVBoxHeight=height*0.3;
        teacherInfoRightVBox.setMaxHeight(teacherInfoRightVBoxHeight);
        teacherInfoRightVBox.setPrefWidth(width*0.5);
        teacherInfoHBox.getChildren().add(teacherInfoRightVBox);

        //账号盒子
        HBox accountHBox = new HBox();
        accountHBox.setSpacing(20);
        double accountHBoxHeight=height*0.05;
        accountHBox.setPrefHeight(accountHBoxHeight);
        accountHBox.setPrefWidth(width);
        Label accountLab = new Label("账号");
        accountLab.setPrefWidth(100);
        TextField accountTF = new TextField();
        accountTF.setId("accountTF");
        accountHBox.getChildren().addAll(accountLab,accountTF);

        //证件类型盒子
        HBox certificateHBox = new HBox();
        certificateHBox.setSpacing(20);
        double certificateHBoxHeight=height*0.05;
        certificateHBox.setPrefHeight(certificateHBoxHeight);
        certificateHBox.setPrefWidth(width);
        Label certificateLb = new Label("证件类型");
        certificateLb.setPrefWidth(100);
        ComboBox certificateCB = new ComboBox();
        certificateCB.getSelectionModel().select("身份证");
        certificateCB.getItems().add("身份证");
        certificateCB.getItems().add("护照");
        certificateCB.setId("certificateCB");
        certificateHBox.getChildren().addAll(certificateLb,certificateCB);
        //性别盒子
        HBox genderHBox = new HBox();
        genderHBox.setSpacing(20);
        double genderHBoxHeight=height*0.05;
        genderHBox.setPrefHeight(genderHBoxHeight);
        genderHBox.setPrefWidth(width);
        Label genderLb = new Label("性别");
        genderLb.setPrefWidth(100);
        ComboBox genderComboBox = new ComboBox();
        genderComboBox.getSelectionModel().select("男");
        genderComboBox.setId("genderComboBox");
        genderComboBox.getItems().add("男");
        genderComboBox.getItems().add("女");
        genderHBox.getChildren().addAll(genderLb,genderComboBox);
        //籍贯盒子
        HBox birthplaceHBox = new HBox();
        birthplaceHBox.setSpacing(20);
        double birthplaceHBoxHeight=height*0.05;
        birthplaceHBox.setPrefHeight(birthplaceHBoxHeight);
        birthplaceHBox.setPrefWidth(width);
        Label birthplaceLb = new Label("籍贯");
        birthplaceLb.setPrefWidth(100);
        TextField birthplaceTF = new TextField();
//        ComboBox provinceCB = new ComboBox();
//        provinceCB.getSelectionModel().select("省");
//        provinceCB.getItems().add("山东省");
//        provinceCB.getItems().add("北京");
//        ComboBox cityCB = new ComboBox();
//        cityCB.getSelectionModel().select("市");
//        cityCB.getItems().add("济南市");
//        cityCB.getItems().add("北京");
//        ComboBox countyTownCB = new ComboBox();
//        countyTownCB.getSelectionModel().select("省");
//        countyTownCB.getItems().add("山东省");
//        countyTownCB.getItems().add("北京");

        birthplaceTF.setId("birthplaceTF");
        birthplaceHBox.getChildren().addAll(birthplaceLb,birthplaceTF);
        //政治面貌盒子
        HBox politicsStatusHBox = new HBox();
        politicsStatusHBox.setSpacing(20);
        double politicsStatusHBoxHeight=height*0.05;
        politicsStatusHBox.setPrefHeight(politicsStatusHBoxHeight);
        politicsStatusHBox.setPrefWidth(width);
        Label politicsStatusLb = new Label("政治面貌");
        politicsStatusLb.setPrefWidth(100);
        politicsStatusCom = new ComboBox<>();
        politicsStatusCom.setId("politicsStatusCom");
        politicsStatusCom.getSelectionModel().select("群众");
        politicsStatusCom.getItems().add("党员");
        politicsStatusCom.getItems().add("团员");
        politicsStatusCom.getItems().add("群众");
        politicsStatusHBox.getChildren().addAll(politicsStatusLb,politicsStatusCom);
        //专业盒子
        HBox specialtyHBox = new HBox();
        specialtyHBox.setSpacing(20);
        double specialtyHBoxHeight=height*0.05;
        specialtyHBox.setPrefHeight(specialtyHBoxHeight);
        specialtyHBox.setPrefWidth(width);
        Label specialtyLb = new Label("专业*");
        specialtyLb.setPrefWidth(100);
        TextField specialtyTf = new TextField();
        specialtyTf.setId("specialtyTF");
        specialtyHBox.getChildren().addAll(specialtyLb,specialtyTf);
        //最高学历盒子
        HBox highestDegreeHBox = new HBox();
        highestDegreeHBox.setSpacing(20);
        double educationHBoxHeight=height*0.05;
        highestDegreeHBox.setPrefHeight(educationHBoxHeight);
        highestDegreeHBox.setPrefWidth(width);
        Label highestDegreeLb = new Label("最高学历*");
        highestDegreeLb.setPrefWidth(100);
        ComboBox<String> highestDegreeCom = new ComboBox<>();
        highestDegreeCom.setId("highestDegreeCom");
        highestDegreeCom.getSelectionModel().select("本科");
        highestDegreeCom.getItems().add("博士");
        highestDegreeCom.getItems().add("硕士");
        highestDegreeCom.getItems().add("本科");
        highestDegreeCom.getItems().add("荣誉博士");
        highestDegreeHBox.getChildren().addAll(highestDegreeLb,highestDegreeCom);
        //移动电话盒子
        HBox phoneHBox = new HBox();
        phoneHBox.setSpacing(20);
        double movePhoneHBoxHeight=height*0.05;
        phoneHBox.setPrefHeight(movePhoneHBoxHeight);
        phoneHBox.setPrefWidth(width);
        Label phoneLb = new Label("移动电话*");
        phoneLb.setPrefWidth(100);
        TextField phoneTf = new TextField();
        phoneTf.setId("phoneTF");
        phoneHBox.getChildren().addAll(phoneLb,phoneTf);
        teacherInfoLeftVBox.getChildren().addAll(accountHBox,certificateHBox,genderHBox,birthplaceHBox,politicsStatusHBox,specialtyHBox,highestDegreeHBox,phoneHBox);


        //姓名盒子
        HBox nameHBox = new HBox();
        nameHBox.setSpacing(20);
        double nameHBoxHeight=height*0.05;
        nameHBox.setPrefHeight(nameHBoxHeight);
        nameHBox.setPrefWidth(width);
        Label nameLb = new Label("姓名*");
        nameLb.setPrefWidth(100);
        TextField nameTF = new TextField();
        nameTF.setId("nameTF");
        nameHBox.getChildren().addAll(nameLb,nameTF);
        //证件号码盒子
        HBox certificateNumberHBox = new HBox();
        certificateNumberHBox.setSpacing(20);
        double certificateNumberHBoxHeight=height*0.05;
        certificateNumberHBox.setPrefHeight(certificateNumberHBoxHeight);
        certificateNumberHBox.setPrefWidth(width);
        Label certificateNumberLb = new Label("证件号码*");
        certificateNumberLb.setPrefWidth(100);
        TextField certificateNumberTF = new TextField();
        certificateNumberTF.setId("certificateNumberTF");
        certificateNumberHBox.getChildren().addAll(certificateNumberLb,certificateNumberTF);
        //出生日期盒子
        HBox birthdateHBox = new HBox();
        birthdateHBox.setSpacing(20);
        double birthdateHBoxHeight=height*0.05;
        birthdateHBox.setPrefHeight(birthdateHBoxHeight);
        birthdateHBox.setPrefWidth(width);
        Label birthdateLb = new Label("出生日期*");
        birthdateLb.setPrefWidth(100);
        DatePicker birthdateDP = new DatePicker();
        birthdateDP.setId("birthdateDP");
        birthdateHBox.getChildren().addAll(birthdateLb,birthdateDP);
        //民族盒子
        HBox nationHBox = new HBox();
        nationHBox.setSpacing(20);
        double nationHBoxHeight=height*0.05;
        nationHBox.setPrefHeight(nationHBoxHeight);
        nationHBox.setPrefWidth(width);
        Label nationLb = new Label("民族*");
        nationLb.setPrefWidth(100);
        TextField nationTF = new TextField();
        nationTF.setId("nationTF");
        nationHBox.getChildren().addAll(nationLb,nationTF);
        //所属的学习中心盒子
        HBox unitHBox = new HBox();
        unitHBox.setSpacing(20);
        double unitHBoxHeight=height*0.05;
        unitHBox.setPrefHeight(unitHBoxHeight);
        unitHBox.setPrefWidth(width);
        Label unitLb = new Label("所属的学习中心*");
        unitLb.setPrefWidth(100);
        ComboBox<String> unitCom = new ComboBox<>();
        unitCom.setId("unitCom");
        unitCom.getSelectionModel().select("北京师范大学");
        unitCom.getItems().add("北京师范大学");
        unitCom.getItems().add("北京大学");
        unitHBox.getChildren().addAll(unitLb,unitCom);
        //职称盒子
        HBox rankHBox = new HBox();
        rankHBox.setSpacing(20);
        double rankHBoxHeight=height*0.05;
        rankHBox.setPrefHeight(rankHBoxHeight);
        rankHBox.setPrefWidth(width);
        Label rankLb = new Label("职称*");
        rankLb.setPrefWidth(100);
        TextField rankTF = new TextField();
        rankTF.setId("rankTF");
        rankHBox.getChildren().addAll(rankLb,rankTF);
        //教龄盒子
        HBox seniorityHBox = new HBox();
        seniorityHBox.setSpacing(20);
        double seniorityHBoxHeight=height*0.05;
        seniorityHBox.setPrefHeight(seniorityHBoxHeight);
        seniorityHBox.setPrefWidth(width);
        Label seniorityLb = new Label("教龄*");
        seniorityLb.setPrefWidth(100);
        TextField seniorityTF = new TextField();
        seniorityTF.setId("seniorityTF");
        seniorityHBox.getChildren().addAll(seniorityLb,seniorityTF);
        teacherInfoRightVBox.getChildren().addAll(nameHBox,certificateNumberHBox,birthdateHBox,nationHBox,unitHBox,rankHBox,seniorityHBox);


        //备注盒子
        HBox remarkHBox = new HBox();
        remarkHBox.setSpacing(20);
        remarkHBox.setAlignment(Pos.CENTER_LEFT);
        remarkHBox.setPadding(new Insets(0,0,0,30));
        double outcomeHBoxHeight=height*0.1;
        remarkHBox.setPrefHeight(outcomeHBoxHeight);
        remarkHBox.setPrefWidth(width);
        Label remarkLb = new Label("备注");
        remarkLb.setPrefWidth(100);
        TextArea remarkTA = new TextArea();
        remarkTA.setId("remarkTA");
        remarkHBox.getChildren().addAll(remarkLb,remarkTA);
        dataVBox.getChildren().add(remarkHBox);

        //照片盒子
        HBox pictureHBox = new HBox();
        pictureHBox.setAlignment(Pos.CENTER_LEFT);
        pictureHBox.setPadding(new Insets(20,0,0,30));
        pictureHBox.setSpacing(20);
        double pictureHBoxHeight=height*0.1;
        pictureHBox.setPrefHeight(pictureHBoxHeight);
        pictureHBox.setPrefWidth(width);
        Label pictureLb = new Label("照片");
        pictureLb.setPrefWidth(100);
        TextField pictureTF = new TextField();
        Button selectBtn = new Button("选择文件");
        Button putBtn = new Button("上传");
        pictureHBox.getChildren().addAll(pictureLb,pictureTF,selectBtn,putBtn);
        dataVBox.getChildren().add(pictureHBox);
//        //继续添加盒子
//        HBox addHBox = new HBox();
//        addHBox.setAlignment(Pos.CENTER_LEFT);
//        addHBox.setPadding(new Insets(20,0,0,30));
//        addHBox.setSpacing(20);
//        double addHBoxHeight=height*0.1;
//        addHBox.setPrefHeight(addHBoxHeight);
//        addHBox.setPrefWidth(width);
//        Button addBtn = new Button("继续添加");
//        BtnStyle.addBtn(addBtn);
//        addHBox.getChildren().add(addBtn);
//        totalVBox.getChildren().add(addHBox);
//
//        //继续添加教师基本信息按钮事件
//        TeacherInfoAddBtn teacherInfoAddBtn = new TeacherInfoAddBtn(dataVBox);
//        addBtn.setOnAction(teacherInfoAddBtn);


    }

    /**
     * 保存/取消按钮
     * @param totalVBox 大盒子
     */
    public void initSaveCancelBtn(VBox totalVBox) {
        HBox saveHBox = new HBox();
        saveHBox.setAlignment(Pos.CENTER);
        saveHBox.setSpacing(20);
        saveHBox.setPadding(new Insets(15, 15, 15, 15));
        double saveHBoxHeight = height * 0.1;
        saveHBox.setPrefHeight(saveHBoxHeight);
        saveHBox.setPrefWidth(width);
        Button saveBtn = new Button("保存");
        saveBtn.setPrefWidth(100);
        saveBtn.setStyle("-fx-background-color: #4f82e1");
        Button cancelBtn = new Button("取消");
        cancelBtn.setPrefWidth(100);
        cancelBtn.setStyle("-fx-background-color: #d22049");
        saveHBox.getChildren().addAll(saveBtn, cancelBtn);
        totalVBox.getChildren().add(saveHBox);


        //保存按钮加事件
        AddTeacherBasicInfoSaveBtnAction addTeacherBasicInfoSaveBtnAction = new AddTeacherBasicInfoSaveBtnAction(this);
        saveBtn.setOnAction(addTeacherBasicInfoSaveBtnAction);


        //取消按钮加事件
        CancelAddTeacherBtn cancelAddTeacherBtnAction = new CancelAddTeacherBtn();
        cancelBtn.setOnAction(cancelAddTeacherBtnAction);

    }
}
